<!--
* description: 商城订单查询
* author: xiaochengzuan
* createdDate: 2021-3-4
-->

<template>
  <div class="app-container app-container-table">
    <one-table-template
      ref="multipleTable"
      :key="oneTableKey"
      :dynamic-buttons="tableButtons"
      :dynamic-components="tableComponents"
      :dynamic-api-config="apiConfig"
      :dynamic-table-cols="tableCols"
      :dynamic-form-fields="formField"
      :dynamic-is-show-select="false"
      :dynamic-is-init-table="true"
      :dynamic-api-style="'restful'"
    />

    <!-- <edit
      :key="editPopupsKey"
      :dynamic-edit-row-data="editRowData"
      :popups-visible="editPopupsVisible"
      :popups-state="editPopupsState"
      :dynamic-api-style="'restful'"
      @close="close"
    /> -->
  </div>
</template>
<script>

import { oneTableWithViewTemplateMixins } from '@/components/mixins/oneTableWithViewTemplateMixins'
import OneTableTemplate from '@/components/templates/oneTable'
import Vue from 'vue'

export default {
  name: 'shoppingMallOrderInquiry',

  components: {
    OneTableTemplate,
    // Edit: () => import('./edit')
  },
  // 组件混入对象
  mixins: [oneTableWithViewTemplateMixins],

  // 阻塞路由预加载网格中组件的数据
  beforeRouteEnter(to, from, next) {
    Vue.prototype.$ConfigCache.CacheConfig.initData([to.path, ''], function() {
      next()
    })
  },

  data() {
    // 页面标识（与上面beforeRouteEnter中的对应）
    const viewPageCode = this.$route.path

    // 绑定事件配置化事件
    this.$ConfigCache.CacheConfig.bindEvent(this, [viewPageCode])

    return {
      editRowData: {},
      // 网格查询API配置对象
      apiConfig: {
        ServiceCode: 'queryBigArea',
        APIUrl: '/mp/e3sh/basics/ve/bigareaService/queryBigArea.do'
      },

      // 动态组件-按钮
      tableButtons: [
        {
          compKey: 'btnKey1',
          type: 'primary',
          size: 'small',
          name: 'search',
          clickEvent: () => this.queryTable(1),
          text: this.$t('sys.button.query'), // 查询
          position: 'right',
          fuzzySearch: true
        },
        //    {
        //   compKey: 'btnKey3',
        //   type: '',
        //   size: 'small',
        //   name: '',
        //   // clickEvent: this.add,
        //   text: '导入', // 新增
        //   position: 'right'
        // },
        //    {
        //   compKey: 'btnKey3',
        //   type: '',
        //   size: 'small',
        //   name: 'add',
        //   clickEvent: this.add,
        //   text: this.$t('sys.button.add'), // 新增
        //   position: 'right'
        // },

      
        
      
           {
              compKey: 'btnKey3',
              type: '',
              size: 'small',
              name: 'export',
              position: 'right',
              clickEvent: () => this.export(), //导出
              text: '导出'
            },
        {
          compKey: 'btnKey2',
          type: '',
          size: 'small',
          name: 'reset',
          clickEvent: () => this.reset(),
          text: this.$t('sys.button.reset'),
          position: 'right' // 重置
        },
         
          
     
       
      ],

      // 动态组件-查询条件
      tableComponents:
        this.$ConfigCache.CacheConfig.cacheData[this.$route.path] &&
        this.$ConfigCache.CacheConfig.cacheData[this.$route.path]
          .tableComponents &&
        this.$ConfigCache.CacheConfig.cacheData[this.$route.path]
          .tableComponents.length > 0
          ? this.$ConfigCache.CacheConfig.cacheData[this.$route.path]
            .tableComponents
          : [

                     {
              compKey: 'compKey1',
              labelName: '商品类别: ',
              codeField: 'bigAreaCode1',
              component: () => import('@/components/org/LookupValue'),
              type: 'dropdownList',
               oFields: 'statusId,statusText',
                options: [
                { statusId: '1', statusText: '启用' },
                { statusId: '0', statusText: '停用' }
              ],
              isMul: false,
              isMust: true
            },

            
                     {
              compKey: 'compKey2',
              labelName: '总部发货: ',
              codeField: 'bigAreaCode2',
              component: () => import('@/components/org/LookupValue'),
              type: 'dropdownList',
               oFields: 'statusId,statusText',
                options: [
                { statusId: '1', statusText: '启用' },
                { statusId: '0', statusText: '停用' }
              ],
              isMul: false,
              isMust: true
            },

                   {
                compKey: "compKey3",
                labelName: "网点编码: ",
                codeField: "bigAreaCode3",
                  component: () => import('@/components/ve/carStockHouse'),
                oFields: "statusId,statusText",
                options: [
                  { statusId: "1", statusText: "厂家备件" },
                  { statusId: "0", statusText: "网点备件" },
                ],
                type: "dropdownList",
                isMul: false,
                isMust: true,
              },





            {
              compKey: 'compKey4',
              labelName: '网点名称：',
              codeField: 'bigAreaCode4',
              component: () => import('@/components/org/commonInput'),
              type: 'inputText',
              isMul: false,
              isMust: true
            },
            {
              compKey: 'compKey5',
              labelName: '备件编码：',
              codeField: 'bigAreaCode5',
              component: () => import('@/components/org/commonInput'),
              type: 'inputText',
              isMul: false,
              isMust: false
            },



             {
              compKey: 'compKey6',
              labelName: '备件名称：',
              codeField: 'bigAreaCode6',
              component: () => import('@/components/org/commonInput'),
              type: 'inputText',
              isMul: false,
              isMust: false
            },

               {
              compKey: 'compKey7',
              labelName: '销售时间：',
              codeField: 'bigAreaCode7',
              component: () => import('@/components/org/datePicker/andtDatePicker'),
              type: 'andtDatePicker',
              isMul: false,
              isMust: false
            },
          ],

      // 动态生成网格列
      tableCols:
        this.$ConfigCache.CacheConfig.cacheData[this.$route.path] &&
        this.$ConfigCache.CacheConfig.cacheData[this.$route.path].tableCols &&
        this.$ConfigCache.CacheConfig.cacheData[this.$route.path].tableCols
          .length > 0
          ? this.$ConfigCache.CacheConfig.cacheData[this.$route.path].tableCols
          : [
            {
              prop: 'releaseId',
              label: '主键ID',
              hidden: true,
              alwaysHidden: true
            },
            {
              prop: 'updateControlId',
              label: '并发控制ID',
              hidden: true,
              alwaysHidden: true
            },
            // {
            //   prop: 'controlBtn1',
            //   label: '操作',
            //   minWidth: 180,
            //   isComponent: true,
            //   comps: [
            //     {
            //       compKey: 'propKey1',
            //       labelName: '修改',
            //       component: () => import('@/components/org/linkButton'),
            //       clickEvent: (index) => this.edit(index)
            //     }
            //   ]
            // },

             {
              prop: 'bigAreaId',
              label: '套餐类型',
              hidden: false,
            //   alwaysHidden: true
            },
             {
              prop: 'bigAreaId',
              label: '备件编号',
              hidden: false,
            //   alwaysHidden: true
            },
            {
              prop: 'bigAreaId',
              label: '备件名称',
              hidden: false,
            //   alwaysHidden: true
            },
            {
              prop: 'bigAreaCode',
              label: '备件数量'
            },
                 {
              prop: 'bigAreaCode',
              label: '销售单号'
            },
                 {
              prop: 'bigAreaCode',
              label: '原总价'
            },
                  {
              prop: 'bigAreaCode',
              label: '折后总金额'
            },
                   {
              prop: 'bigAreaCode',
              label: '折扣总金额'
            },
                   {
              prop: 'bigAreaCode',
              label: '销售时间'
            },
                       {
              prop: 'bigAreaCode',
              label: '是否总部发货'
            },
                       {
              prop: 'bigAreaCode',
              label: '网点编码'
            },
                       {
              prop: 'bigAreaCode',
              label: '网点名称'
            },
          ],

      // 表单查询数据
      formField: this.$utils.getFormField(this, {
          bigAreaCode1:'',
          bigAreaCode2:'',
          bigAreaCode3:'',
          bigAreaCode4:'',
          bigAreaCode5:'',
          bigAreaCode6:'',



        bigAreaCode: '',
        bigAreaName1: '',
        bigAreaName2: '',
        bigAreaName3: '',
        bigAreaName4: '',
        isEnable: '',
        isEnable1: '',
        bigAreaId: '',
        updateControlId: ''
      }, this.$ConfigCache.CacheConfig.cacheData[viewPageCode])
    }
  },

  mounted() {
    // 列表查询
    this.queryTable(1)
      this.$refs['multipleTable'].list=[
      {releaseId:'1',updateControlId:'1'}
    ]
  },

  methods: {
    // 编辑获取数据
    edit(index) {
      this.editPopupsState = 'edit'
      this.editPopupsVisible = true
      this.editRowData = this.$utils.deepCopy(this.$refs['multipleTable'].list[index])
    },


        //导出
    export() {
      var date = new Date;
      var year=date.getFullYear()
      var month=date.getMonth()+1
      var day=date.getDate();
          month =(month<10 ? "0"+month:month)
          day =(day<10 ? "0"+day:day)
      var mydate = year.toString()+month.toString()+day.toString()
      const returnObj = {
          // api配置
        apiConfig: {
          APIUrl:'/mp/e3sh/basics/ve/CarTypeService/exportCarType.do',
        },
          variables: this.formField
        }
        returnObj.variables.dataType='excel'
        const paramD = this.$getParams(returnObj)
        this.$requestAPI(paramD).then(res=>{
        this.$utils.downloadFile(res,`车系维护${mydate}.xlsx`)
      })
    },
  }
}
</script>
